package edu.kit.csl.cratyli.control;

import edu.kit.csl.cratyli.datatypes.Dictionary;

/**
 * This target function selects the sentence with the maximum sum of word
 * weights.
 */
public class WeightSentenceTargetFunction extends SentenceTargetFunction {

	/* (non-Javadoc)
	 * @see SentenceTargetFunction#merge(Dictionary, String[], String[])
	 */
	@Override
	public String merge(Dictionary dict, String[] prim, String[] sec) {
		double primWeight = 0.0, secWeight = 0.0;
		for (String word : prim) {
			primWeight += dict.get(word).getWeight();
		}
		for (String word : sec) {
			secWeight += dict.get(word).getWeight();
		}
		return arr2str(primWeight >= secWeight ? prim : sec);
	}
}
